package d13_tz.d4_blocking_queue;

import java.util.concurrent.ArrayBlockingQueue;

public class Cook extends Thread{
    private final ArrayBlockingQueue<String> queue;

    public Cook(ArrayBlockingQueue<String> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        //完成池面条的事情
        while(true){
            try {
                queue.put("大包子");//底层是有锁的
                System.out.println("生产了一个大包子");//注意--->是放在锁外面的,可能会出错
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

        }
    }
}